import React from 'react'
import ReactDOM from 'react-dom'

class EssayForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = { value: '' };
    this.handleSubmit = this.handleSubmit.bind(this);
    this.handleChange = this.handleChange.bind(this);
  }
  handleChange(e) {
    this.setState({value: e.target.value})
  }
  handleSubmit(e) {
    console.log('提交的文章：' + this.state.value);
    e.preventDefault();
  }
  render() {
    return (
      <form onSubmit={this.handleSubmit}>
        <label>
          <textarea value={this.state.value} onChange={this.handleChange} placeholder="请撰写一篇关于dom的文章"></textarea>
        </label>
        <input type="submit" value="提交"></input>
      </form>
    )
  }
}

ReactDOM.render(
  <EssayForm />,
  document.getElementById('root')
)